import React from "react";
import { Redirect } from "react-router-dom";

// import index from "../views/index";
// import askQuestions from "../views/ask-questions";
// import news from "../views/news";
// import shop from "../views/shop";

const index = React.lazy(() => import("../views/index"));
const askQuestions = React.lazy(() => import("../views/ask-questions"));
const askDistory = React.lazy(() =>
  import("../views/ask-questions/child/discover")
);
const askProblem = React.lazy(() =>
  import("../views/ask-questions/child/problem")
);
const askTree = React.lazy(() =>
  import("../views/ask-questions/child/tree-hole")
);
const askLife = React.lazy(() => import("../views/ask-questions/child/life"));
const askWork = React.lazy(() => import("../views/ask-questions/child/work"));
const askFish = React.lazy(() => import("../views/ask-questions/child/fish"));
const askMomentDetail = React.lazy(() =>
  import("../views/ask-questions/child/user/child/moment-detail")
);
const askDaily = React.lazy(() => import("../views/ask-questions/child/daily"));
const news = React.lazy(() => import("../views/news"));
const shop = React.lazy(() => import("../views/shop"));
const articleDetail = React.lazy(() => import("@/components/article-detail"));
const login = React.lazy(() => import("@/components/login"));
const write = React.lazy(() => import("@/components/write-article"));
const user = React.lazy(() => import("@/components/user"));
const userArticle = React.lazy(() => import("@/components/user/child/article"));
const userBuddy = React.lazy(() => import("@/components/user/child/buddy"));
const userCollect = React.lazy(() => import("@/components/user/child/collect"));
const userForum = React.lazy(() => import("@/components/user/child/forum"));
const userOrder = React.lazy(() => import("@/components/user/child/order"));
const userVip = React.lazy(() => import("@/components/user/child/vip"));
const bulletin = React.lazy(() => import("@/components/bulletin"));
const goodsDetail = React.lazy(() => import("@/components/goods-detail"));
const WaitingForPay = React.lazy(() =>
  import("@/components/user/child/order/child/WaitingForPay")
);
const WaitForDelivery = React.lazy(() =>
  import("@/components/user/child/order/child/WaitForDelivery")
);
const WaitingForReceipt = React.lazy(() =>
  import("@/components/user/child/order/child/WaitingForReceipt")
);
const WaitingForComment = React.lazy(() =>
  import("@/components/user/child/order/child/WaitingForComment")
);
const AllOrders = React.lazy(() =>
  import("@/components/user/child/order/child/AllOrders")
);
const OrdersConfirmPage = React.lazy(() => import("@/components/order"));
const routes = [
  {
    path: "/",
    exact: true,
    render: () => <Redirect to="/index" />,
  },
  {
    path: "/index",
    component: index,
  },
  {
    path: "/ask",
    component: askQuestions,
    routes: [
      {
        path: "/ask",
        exact: true,
        render: () => <Redirect to="/ask/discover" />,
      },
      {
        path: "/ask/discover",
        component: askDistory,
      },
      {
        path: "/ask/problem",
        component: askProblem,
      },
      {
        path: "/ask/tree",
        component: askTree,
      },
      {
        path: "/ask/daily",
        component: askDaily,
      },
      {
        path: "/ask/life",
        component: askLife,
      },
      {
        path: "/ask/work",
        component: askWork,
      },
      {
        path: "/ask/fish",
        component: askFish,
      },
    ],
  },
  {
    path: "/news",
    component: news,
  },
  {
    path: "/shop",
    component: shop,
  },
  {
    path: "/articleDetail",
    component: articleDetail,
  },
  {
    path: "/login",
    component: login,
  },
  {
    path: "/write",
    component: write,
  },
  {
    path: "/user",
    component: user,
    routes: [
      {
        path: "/user",
        exact: true,
        render: () => <Redirect to="/user/collect" />,
      },
      {
        path: "/user/article",
        component: userArticle,
      },
      {
        path: "/user/collect",
        component: userCollect,
      },
      {
        path: "/user/buddy",
        component: userBuddy,
      },
      {
        path: "/user/forum",
        component: userForum,
      },
      {
        path: "/user/order",
        component: userOrder,
        routes: [
          {
            path: "/user/order",
            exact: true,
            render: () => <Redirect to="/user/order/WaitingForPay" />,
          },
          {
            path: "/user/order/WaitingForPay",
            component: WaitingForPay,
          },
          {
            path: "/user/order/WaitForDelivery",
            component: WaitForDelivery,
          },
          {
            path: "/user/order/WaitingForReceipt",
            component: WaitingForReceipt,
          },
          {
            path: "/user/order/WaitingForComment",
            component: WaitingForComment,
          },
          {
            path: "/user/order/AllOrders",
            component: AllOrders,
          },
        ],
      },
      {
        path: "/user/vip",
        component: userVip,
      },
    ],
  },
  {
    path: "/bulletin",
    component: bulletin,
  },
  {
    path: "/momentdetail",
    component: askMomentDetail,
  },
  {
    path: "/goodsdetail",
    component: goodsDetail,
  },
  {
    path: "/OrdersConfirmPage",
    component: OrdersConfirmPage,
  },
];

export default routes;
